package com.motong.gongdan.vo.system.AssemblyWorkOrder.query;

import cn.hutool.core.convert.Convert;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Data
public class ListByProductIdQuery {

    @ApiModelProperty("属性ids(多个以,号隔开)")
    private String productIds;

    @ApiModelProperty(value = "获取产品子集(0 否,1 是)")
    private Integer getChild = 1;

    @ApiModelProperty(value = "产品id数组", hidden = true)
    private List<Integer> productIdList = new ArrayList<>();

    /*逗号分隔格式化为数组*/
    public void setProductIds(String productIds) {
        if (StringUtils.hasLength(productIds)) {
            List<String> stringProductIds = Arrays.asList(productIds.split(","));
            stringProductIds.forEach(i -> productIdList.add(Convert.toInt(i)));
        }
        this.productIds = productIds;
    }

}
